import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import dayjs from 'dayjs';
import { HydratedDocument } from 'mongoose';
import mongoose from 'mongoose';

@Schema()
export class Order {
  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User', populate: true })
  creatorId: mongoose.Schema.Types.ObjectId;

  @Prop({ type: String, default: '' })
  passenger: string;

  @Prop({ type: String, default: '' })
  identityNumber: string;

  @Prop({ type: String, default: '' })
  mobile: string;

  @Prop({ type: String, default: '' })
  trainNo: string;

  @Prop({ type: String, default: '' })
  coachNo: string;

  @Prop({ type: String, default: '' })
  seatNo: string;

  @Prop({ type: String, default: '' })
  seatLevel: string;

  @Prop({ type: String, default: '' })
  fromStationNo: string;

  @Prop({ type: String, default: '' })
  fromStationName: string;

  @Prop({ type: String, default: '' })
  toStationNo: string;

  @Prop({ type: String, default: '' })
  toStationName: string;

  @Prop({ type: String, default: '' })
  departureTime: string;

  @Prop({ type: String, default: '' })
  arrivalTime: string;

  @Prop({ type: Number, default: '' })
  price: number;

  @Prop({ type: String, default: () => dayjs().format('YYYY-MM-DD HH:mm:ss') })
  createdAt: string;

  @Prop({ type: String, default: '' })
  updatedAt: string;
}

export type OrderDocument = HydratedDocument<Order>;

export const OrderSchema = SchemaFactory.createForClass(Order);
